//
//  DualMediationMAXInterstitialManager.h
//  DualMediationSDK
//
//  Created by YeJary on 2025/1/15.
//

#import <Foundation/Foundation.h>
#import "DMAdDelegate.h"
#import "DMInterstitialScenes.h"

#if __has_include(<UIKit/UIKit.h>)
#import <UIKit/UIKit.h>
#define UIKIT_AVAILABLE 1
#else
#define UIKIT_AVAILABLE 0
@class UIViewController;
#endif

NS_ASSUME_NONNULL_BEGIN

@interface DualMediationMAXInterstitialManager : NSObject

// 新增属性 - 与Android接口对齐
@property (nonatomic, weak) id<DMAdDelegate> delegate;
@property (nonatomic, assign) BOOL interTimeSceneEnabled;

// 保留原有属性
@property (nonatomic, assign) BOOL isLoadInterstitial;
@property (nonatomic, assign, readonly) BOOL isUserClosed;

// 双广告位支持属性
@property (nonatomic, assign) BOOL isDualAdEnabled;
@property (nonatomic, strong) NSString *currentPrimaryAdUnitId;
@property (nonatomic, strong) NSString *currentSecondaryAdUnitId;
@property (nonatomic, assign) BOOL isPrimaryAdLoaded;
@property (nonatomic, assign) BOOL isSecondaryAdLoaded;
@property (nonatomic, assign) double primaryAdECPM;
@property (nonatomic, assign) double secondaryAdECPM;

// 重试机制相关属性
@property (nonatomic, assign) NSInteger maxRetryCount;
@property (nonatomic, assign) NSInteger retryCount;
@property (nonatomic, assign) NSInteger totalLoadAttempts;
@property (nonatomic, assign) NSInteger totalFailureCount;
@property (nonatomic, strong) NSDate *lastRetryTime;
@property (nonatomic, assign) BOOL isRetryPaused;
@property (nonatomic, strong) NSTimer *retryTimer;

// 新增方法 - 与Android接口对齐
+ (instancetype)sharedInterstitialManager;
- (void)showInterAd:(NSString *)adScene;
- (void)setInterTimeSceneEnable:(BOOL)enable;
- (void)loadInterstitial;
- (BOOL)isAdReady;
- (BOOL)isInterstitialReady;

// 双广告位支持方法
- (void)loadDualInterstitialAds;
- (NSString *)selectOptimalAdUnitId;
- (void)switchToSecondaryAdIfNeeded;

// 保留原有方法（兼容性）
- (void)setInterstitialDelegate;
- (void)showInterstitial; // 调用showInterAd:SCENE_INTER_LEVEL_WIN
- (void)closeInterstitial;
- (void)resumeInterstitial;
- (void)checkPendingInterstitialDisplay;

@end

NS_ASSUME_NONNULL_END
